package com.xh.demo.mq.stream;

import com.xh.demo.mq.stream.source.NoticeMessageInputSource;
import com.xh.demo.mq.stream.source.consts.NoticeMessageConst;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

/**
 * @author wen
 * @apiNote 消息通知MQ消费者
 * @since 2021-06-01
 */
@Slf4j
@Component
@EnableBinding({NoticeMessageInputSource.class})
public class NoticeConsumer {

    @StreamListener(NoticeMessageInputSource.IN_PUT)
    public void handle(String value, @Header(NoticeMessageConst.HEAD) String version) {
        log.info("【消息服务-STREAM-MQ异步消息通知-接收消息】【{}】【{}】", value, version);
        if (!NoticeMessageConst.HEAD_VALUE.equals(version)) return;
        // TODO do something
    }


}
